package com.webdrider.servlet.action.system;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.common.model.abstracts.AbstractRequest;
import com.common.model.abstracts.AbstractValidator;
import com.common.security.exceptions.HTTPException;
import com.common.security.exceptions.ParserException;
import com.common.servlet.abstracts.AbstractServlet;
import com.common.servlet.interfaces.IParser;
import com.google.appengine.api.channel.ChannelMessage;
import com.google.appengine.api.channel.ChannelService;
import com.google.appengine.api.channel.ChannelServiceFactory;
import com.webdrider.model.requests.system.SendChannelDataRequest;
import com.webdrider.servlet.util.parser.system.SendChannelDataXMLParser;

public class SendChannelDataServlet extends AbstractServlet {
	private static final long serialVersionUID = 1L;
	private static Set<AbstractValidator> validators = new HashSet<AbstractValidator>();

	private SendChannelDataRequest requestContent;
	private SendChannelDataXMLParser parser = new SendChannelDataXMLParser();
	
	@Override
	public void handle(HttpServletRequest request, HttpServletResponse response) {
		ChannelService service = ChannelServiceFactory.getChannelService();
		System.out.println("Here");
		
		String token = "secret";
		
		service.sendMessage(new ChannelMessage(token, "Hello dude"));
		
	}

	@Override
	public void setRequest(AbstractRequest abstractRequest) {
		requestContent = (SendChannelDataRequest) abstractRequest;
	}

	@Override
	public Set<AbstractValidator> getValidators() {
		return validators;
	}

	@Override
	public IParser parser() {
		return parser;
	}

	@Override
	public AbstractRequest parseRequest(HttpServletRequest request)
			throws ParserException, HTTPException, IOException {
		// TODO Auto-generated method stub
		return null;
	}
}
